package com.muyu.system.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.system.domain.DanmoMarketPickUp;
import com.muyu.system.service.IDanmoMarketPickUpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 书画市场上门取件Controller
 * 
 * @author kunzong
 * @date 2024-12-27
 */
@RestController
@RequestMapping("/DanmoMarketPickUp")
public class DanmoMarketPickUpController extends BaseController
{
    @Autowired
    private IDanmoMarketPickUpService danmoMarketPickUpService;

    /**
     * 查询书画市场上门取件列表
     */
    @RequiresPermissions("system:DanmoMarketPickUp:list")
    @GetMapping("/list")
    public Result list(DanmoMarketPickUp danmoMarketPickUp)
    {
        startPage();
        List<DanmoMarketPickUp> list = danmoMarketPickUpService.selectDanmoMarketPickUpList(danmoMarketPickUp);
        return Result.success(list);
    }

    /**
     * 导出书画市场上门取件列表
     */
    @RequiresPermissions("system:DanmoMarketPickUp:export")
    @Log(title = "书画市场上门取件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoMarketPickUp danmoMarketPickUp)
    {
        List<DanmoMarketPickUp> list = danmoMarketPickUpService.selectDanmoMarketPickUpList(danmoMarketPickUp);
        ExcelUtil<DanmoMarketPickUp> util = new ExcelUtil<DanmoMarketPickUp>(DanmoMarketPickUp.class);
        util.exportExcel(response, list, "书画市场上门取件数据");
    }

    /**
     * 获取书画市场上门取件详细信息
     */
    @RequiresPermissions("system:DanmoMarketPickUp:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.success(danmoMarketPickUpService.selectDanmoMarketPickUpById(id));
    }

    /**
     * 新增书画市场上门取件
     */
    @RequiresPermissions("system:DanmoMarketPickUp:add")
    @Log(title = "书画市场上门取件", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoMarketPickUp danmoMarketPickUp)
    {
        return Result.success(danmoMarketPickUpService.insertDanmoMarketPickUp(danmoMarketPickUp));
    }

    /**
     * 修改书画市场上门取件
     */
    @RequiresPermissions("system:DanmoMarketPickUp:edit")
    @Log(title = "书画市场上门取件", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoMarketPickUp danmoMarketPickUp)
    {
        return Result.success(danmoMarketPickUpService.updateDanmoMarketPickUp(danmoMarketPickUp));
    }

    /**
     * 删除书画市场上门取件
     */
    @RequiresPermissions("system:DanmoMarketPickUp:remove")
    @Log(title = "书画市场上门取件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return Result.success(danmoMarketPickUpService.deleteDanmoMarketPickUpByIds(ids));
    }
}
